package com.ruoyi.order.service;

import com.ruoyi.order.domain.OrderOperation;
import com.ruoyi.order.domain.WxVhiceodr;
import com.ruoyi.order.domain.dto.WxVhiceodrDto;
import com.ruoyi.order.domain.vo.WxVhiceodrVo;
import com.ruoyi.order.mapper.WxVhiceodrMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component("BusinessTim")
public class BusinessTim {
    @Autowired
    private WxVhiceodrMapper wxVhiceodrMapper;
    public void updateOrderStatus(){
        System.out.printf("测试定时");
        WxVhiceodrDto sunOrder=new WxVhiceodrDto();
        sunOrder.setStatus(OrderOperation.GENERATE_ORDER);
        List<WxVhiceodrVo> imsOrderList=wxVhiceodrMapper.selectWxVhiceodrList(sunOrder);
        if (ObjectUtils.isNotEmpty(imsOrderList)){
            for(WxVhiceodr yzzcSunOrder:imsOrderList){
                System.out.println(System.currentTimeMillis()- yzzcSunOrder.getCreateTime().getTime());
                if (System.currentTimeMillis()- yzzcSunOrder.getCreateTime().getTime()>1000*60*30L){
                    yzzcSunOrder.setStatus(OrderOperation.CANCEL_ORDERS);
                    wxVhiceodrMapper.updateWxVhiceodr(yzzcSunOrder);
                }
            }
        }
    }
}
